<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8">
	<title>个人设置-学生</title>
	<link rel="stylesheet" href="css/left_style.css">
	<link rel="stylesheet" href="css/common.css">
	<link rel="stylesheet" href="css/per_setup.css">
</head>
<body>
<!-- 加载头部信息 -->
<?php 
	include_once("header.php");
?>


<!-- 中间内容 -->
<div class="content clearfloat">
	<!-- 左边内容 -->
	<div class="left_content">
		<ul class="left_nav" id="left_ul">
			<li><a href="notice.php" class="li_a">
				<span class="text">
					<?php echo "<img src='images/notice.png' alt='图片' class='left_img1'";?>&nbsp;
					<span>动&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;态</span>
				</span>
				<canvas id="canvas_index1" width="18" height="48"></canvas>	
			</a></li>
			<li><a href="" class="li_a">
				<span class="text">
					<?php echo "<img src='images/course.png' alt='图片' class='left_img2'";?>
					<span>我的作业</span>
				</span>
				<canvas id="canvas_index2" width="18" height="48"></canvas>
			</a></li>
			<li><a href="" class="li_a">
				<span class="text">
					<?php echo "<img src='images/mycourse.png' alt='图片' class='left_img3'";?>
					<span>我的课程</span>
				</span>
				<canvas id="canvas_index3" width="18" height="48"></canvas>
			</a></li>
			<li class="active_nav"><a href="per_setup.php" class="li_a">
				<span class="text">
					<?php echo "<img src='images/setup.png' alt='图片' class='left_img4'";?>
					<span>个人设置</span>
				</span>
				<canvas id="canvas_index4" width="18" height="48"></canvas>
			</a></li>
			<li><a href="" class="li_a">
				<span class="text">
					<?php echo "<img src='images/help.png' alt='图片' class='left_img5'";?>&nbsp;
					<span>帮&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;助</span>
				</span>
				<canvas id="canvas_index5" width="18" height="48"></canvas>	
			</a></li>
		</ul>
	</div>

	<!-- 右边内容 -->
	<div class="center_content">
		<a href="per_edit.php" class="per">编辑个人资料</a>
<?php
if(isset($_COOKIE["stu_number"])) {
	$stu_number = $_COOKIE["stu_number"];

	$selectstu = "select * from students where stu_number='$stu_number'";

	include_once("database.php");

	$result = @mysql_query($selectstu) or die("查询学生信息表失败：".mysql_error()."<br/>");

	$row = mysql_fetch_array($result,MYSQL_ASSOC);

	$stu_name = $row["stu_name"];
	$school = $row["school"];
	$stu_phone = $row["stu_phone"];
	$stu_email = $row["stu_email"];
	$stu_province = $row["stu_province"];
	$stu_city = $row["stu_city"];
	$stu_county = $row["stu_county"];
	$stu_sex = $row["stu_sex"];
	$name = $row["name"];
	$stuper_signature = $row["stuper_signature"];
	$stu_touxiang = $row["stu_touxiang"];

	if($stu_touxiang == "" || $stu_touxiang == "imgs/" || $stu_touxiang == "images/touxiang.jpg") {
		$stu_touxiang == "images/touxiang.jpg";
	}

	echo <<<tea_setup
		<form action="" method="post" class="per_infor">
			&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<label for="stu_name">昵称:</label>
			<input type='text' name='stu_name' id='stu_name' value='{$stu_name}'><br/>

			&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<label for="school">学校:</label>
			<input type="text" name="school" id="school" value='{$school}'><br/>
			
			<div class="touxiang">
				<div id="image-holder">
					<img src='{$stu_touxiang}' alt='图片' id='file_img'>
				</div>
			</div>
			
			&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<label for="stu_phone">电话:</label>
			<input type="text" name="stu_phone" id="stu_phone" value='{$stu_phone}'>
			
			<label>所在地区:</label>
			<input type="text" name="stu_province" id="province" value='{$stu_province}'>
			<input type="text" name="stu_city" id="city" value='{$stu_city}'>
			<input type="text" name="stu_county" id="county" value='{$stu_county}'><br/>

			&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<label for="stu_email">邮箱:</label>
			<input type="text" name="stu_email" id="stu_email" value='{$stu_email}'>

			<label for=\"name\">真实姓名:</label>
			<input type=\"text\" name=\"name\" id=\"name\" value='{$name}'><br/>
			
			&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<label>性别:</label>
tea_setup;
}
?>

<?php
		echo	"<div id='sex'><input type=\"radio\" name=\"stu_sex\" value=\"男\" checked=\"checked\" class=\"sex\">&nbsp;&nbsp;男&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
			<input type=\"radio\" name=\"stu_sex\" value=\"女\" class=\"sex\">&nbsp;&nbsp;女</div><br/>";

		echo <<<script_sex
			<script>
				var sex = document.getElementById("sex");
				var input = sex.children;
				var len = input.length;
				for(var i = 0; i < len; i++) {
					input[i].checked = "";

					if(input[i].value == '{$stu_sex}') {
						input[i].checked = "checked";

						if(i == 0) {
							input[1].id = "prohibit";
						} else {
							input[0].id = "prohibit";
						}
					} 
				}
			</script>
script_sex;

		echo 
			"<label for=\"stuper_signature\">个性签名:</label>
			<textarea name=\"stuper_signature\" id=\"stuper_signature\" cols=\"30\" rows=\"10\">{$stuper_signature}</textarea><br/>
		</form>
	</div>";
?>
	
	<!-- 右侧栏 -->
	<?php
		include_once("right_content.php");
	?>
</div>

<!-- 加载左边导航的样式 -->
<?php
	include_once("nav_style.php");
?>

<!-- 加载底部信息 -->
<?php
	include_once("footer.php");
?>

<script src="js/jquery-3.2.1.js"></script>
<script>
    $("#upfile").on('change', function () {
        if (typeof (FileReader) != "undefined") {

            var image_holder = $("#image-holder");
            image_holder.empty();

            var reader = new FileReader();
            reader.onload = function (e) {
                $("<img />", {
                    "src": e.target.result,
                    "class": "thumb-image"
                }).appendTo(image_holder);
            };
            image_holder.show();
            reader.readAsDataURL($(this)[0].files[0]);
        } else {
            alert("你的浏览器不支持FileReader.");
        }
    });

    $("#infile").on('change', function () {
        if (typeof (FileReader) != "undefined") {

            var image_holder = $("#image-holder");
            image_holder.empty();

            var reader = new FileReader();
            reader.onload = function (e) {
                $("<img />", {
                    "src": e.target.result,
                    "class": "thumb-image"
                }).appendTo(image_holder);
            };
            image_holder.show();
            reader.readAsDataURL($(this)[0].files[0]);
        } else {
            alert("你的浏览器不支持FileReader.");
        }
    });
</script>
</body>
</html>